function goto(appUrl = '') {
    WPT.os.wpt && window.wptJumpNativeWithUrl && window.wptJumpNativeWithUrl(appUrl, () => {}, {});
}

function closeWebView(isRefresh) {
    if (WPT.os.version > '1.6.2') {
        goto(`${window.location.host}/nativeBack${isRefresh ? '?isRefresh=1' : ''}`);
    }
}

function closeWebViewUrl(url) {
    if (WPT.os.version > '1.6.2') {
        goto(`${window.location.host}${url}`);
    }
}

function forceGoBack(isRefresh) {
    if (window.history.length === 1) {
        closeWebView && closeWebView(isRefresh);
    }
}

export default {
    goto,
    closeWebView,
    closeWebViewUrl,
    forceGoBack,
};
